﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace SevenInvaders.LEVEL_VINICIUS
{
    class WWolfPlayer : Player
    {
        animation stand;
        animation walk;

        public WWolfPlayer(Texture2D texture, Vector2 position, int player, GameWindow gameWindow, ContentManager Content) :
            base(texture, position, player, gameWindow, Content)
        {

            this.Position = position;
            this.Velocity = new Vector2(5, 0);
            this.Window = gameWindow;
            
            
            stand = new animation();
            stand.frame.X = 0;
            stand.frame.Y = 0;
            stand.frame.Width = 90;
            stand.frame.Height = 88;
            stand.frames = 3;
            stand.fps = 3;
            
            current_animation = stand;

            walk = new animation();
            walk.frame.X = 270;
            walk.frame.Y = 0;
            walk.frame.Width = 90;
            walk.frame.Height = 88;

            walk.frames = 4;
            walk.fps = 4;


        }

        public void Update(GameTime gameTime, KeyboardState ks)
        {
            #region Movimentação
            if (ks.IsKeyDown(Keys.Right))
            {
                current_animation = walk;
                this.Right = true;
                this.PositionX += 2;// this.Velocity.X;
            }
            else if (ks.IsKeyDown(Keys.Left))
            {
                current_animation = walk;
                this.Right = false;
                this.PositionX -= 2;// this.Velocity.X;
            }
            else
            {
                current_animation = stand;
            }
            #endregion

            
            #region Colisao borda da tela
            if (this.PositionX + this.Texture.Bounds.Width > Window.ClientBounds.Width)
            {
                this.PositionX = Window.ClientBounds.Width - this.Texture.Bounds.Width;
            }

            if (this.PositionX <= 0)
            {
                this.PositionX = 0;
            }

            if (this.PositionY + this.Texture.Bounds.Height > Window.ClientBounds.Height)
            {
                this.PositionY = Window.ClientBounds.Height - this.Texture.Bounds.Height;
            }

            if (this.PositionY <= 0)
            {
                this.PositionY = 0;
            }
            #endregion
        }
    }
}
